<template>
  <div class="app-container">
    <el-scrollbar style="height: 100%;margin-top:50px;">
      <div class="echarts-item">
        <div class="echarts-title">
          {{ echartsData.ssh.title }}
        </div>
        <el-row :gutter="15" class="echarts-row" style="height: 500px;">
          <el-col :span="24">
            <echarts :echartsData="echartsData.ssh"></echarts>
          </el-col>
        </el-row>
      </div>


    </el-scrollbar>
  </div>
</template>

<script>
  import Echarts from '@/components/echarts/index'

  var app = {};
  var dataMap = {};
  function dataFormatter(obj) {
    var pList = ['瓮安水务有限责任公司','铜仁水务碧江有限责任公司','绥阳水务有限责任公司','三都水务有限责任公司','贵定水务有限责任公司','桐梓水务有限责任公司'];
    var temp;
    for (var year = 2002; year <= 2018; year++) {
      var max = 0;
      var sum = 0;
      temp = obj[year];
      for (var i = 0, l = temp.length; i < l; i++) {
        max = Math.max(max, temp[i]);
        sum += temp[i];
        obj[year][i] = {
          name : pList[i],
          value : temp[i]
        }
      }
      obj[year + 'max'] = Math.floor(max / 100) * 100;
      obj[year + 'sum'] = sum;
    }
    return obj;
  }



  dataMap.dataPI = dataFormatter({
    //max : 4000,
    //2019:[136.27,159.72,2905.73,641.42,1306.3,1915.57,1277.44,1701.5,124.94,3064.78,1583.04,2015.31,1612.24,1391.07,3973.85,3512.24,2569.3,2768.03,2665.2,2047.23,659.23,844.52,2983.51,726.22,1411.01,74.47,1220.9,678.75,155.08,184.14,1139.03],
    2018:[124.36,145.58,2562.81,554.48,1095.28,1631.08],
    2017:[118.29,128.85,2207.34,477.59,929.6,1414.9],
    2016:[112.83,122.58,2034.59,313.58,907.95,1302.02],
    2015:[101.26,110.19,1804.72,311.97,762.1,1133.42],
    2014:[88.8,103.35,1461.81,276.77,634.94,939.43],
    2013:[88.68,112.38,1400,262.42,589.56,882.41],
    2012:[87.36,105.28,1370.43,276.3,522.8,798.43],
    2011:[136.27,159.72,2905.73,641.42,1306.3,1915.57],
    2010:[124.36,145.58,2562.81,554.48,1095.28,1631.08],
    2009:[118.29,128.85,2207.34,477.59,929.6,1414.9],
    2008:[112.83,122.58,2034.59,313.58,907.95,1302.02],
    2007:[101.26,110.19,1804.72,311.97,762.1,1133.42],
    2006:[88.8,103.35,1461.81,276.77,634.94,939.43],
    2005:[88.68,112.38,1400,262.42,589.56,882.41],
    2004:[87.36,105.28,1370.43,276.3,522.8,798],
    2003:[84.11,89.91,1064.05,215.19,420.1,615.8,],
    2002:[82.44,84.21,956.84,197.8,374.69,590.2]
  });

  dataMap.dataSI = dataFormatter({
    //max : 26600,
    2018:[3752.48,5928.32,13126.86,6635.26,8037.69,12152.15],
    2017:[3388.38,4840.23,10707.68,5234,6367.69,9976.82],
    2016:[2855.55,3987.84,8959.83,3993.8,5114,7906.34],
    2015:[2626.41,3709.78,8701.34,4242.36,4376.19,7158.84],
    2014:[2509.4,2892.53,7201.88,3454.49,3193.67,5544.14],
    2013:[2191.43,2457.08,6110.43,2755.66,2374.96,4566.83],
    2012:[2026.51,2135.07,5271.57,2357.04,1773.21,3869.4],
    2011:[3752.48,5928.32,13126.86,6635.26,8037.69,12152.15],
    2010:[3388.38,4840.23,10707.68,5234,6367.69,9976.825],
    2009:[2855.55,3987.84,8959.83,3993.8,5114,7906.34],
    2008:[2626.41,3709.78,8701.34,4242.36,4376.19,7158.84],
    2007:[2509.4,2892.53,7201.88,3454.49,3193.67,5544.14],
    2006:[2191.43,2457.08,6110.43,2755.66,2374.96,4566.83],
    2005:[2026.51,2135.07,5271.57,2357.04,1773.21,3869.4],
    2004:[1853.58,1685.93,4301.73,1919.4,1248.27,3061.62],
    2003:[1487.15,1337.31,3417.56,1463.38,967.49,2898.89],
    2002:[1249.99,1069.08,2911.69,1134.31,754.78,2609.85]
  });

  dataMap.dataTI = dataFormatter({
    //max : 25000,
    2018:[12363.18,5219.24,8483.17,3960.87,5015.89,8158.98],
    2017:[10600.84,4238.65,7123.77,3412.38,4209.03,6849.37],
    2016:[9179.19,3405.16,6068.31,2886.92,3696.65,5891.25],
    2015:[8375.76,2886.65,5276.04,2759.46,3212.06,5207.72],
    2014:[7236.15,2250.04,4600.72,2257.99,2467.41,4486.74],
    2013:[5837.55,1902.31,3895.36,1846.18,1934.35,3798.26],
    2012:[4854.33,1658.19,3340.54,1611.07,1542.26,3295.45],
    2011:[12363.18,5219.24,8483.17,3960.87,5015.89,8158.98],
    2010:[10600.84,4238.65,7123.77,3412.38,4209.03,6849.37],
    2009:[9179.19,3405.16,6068.31,2886.92,3696.65,5891.25],
    2008:[8375.76,2886.65,5276.04,2759.46,3212.06,5207.72],
    2007:[7236.15,2250.04,4600.72,2257.99,2467.41,4486.74],
    2006:[5837.55,1902.31,3895.36,1846.18,1934.35,3798.26],
    2005:[4854.33,1658.19,3340.54,1611.07,1542.26,3295.45],
    2004:[4092.27,1319.76,2805.47,1375.67,1270,2811.95],
    2003:[3435.95,1150.81,2439.68,1176.65,1000.79,2487.85],
    2002:[2982.57,997.47,2149.75,992.69,811.47,2258.17]
  });

  export default {
    mounted() {
      this.$store.commit('rdefaultActive', 'cwsj')
    },
    components: {
      Echarts,
    },
    data() {
      return {
        schema: [
          { name: 'YM', index: 0, text: '年月' },
          { name: 'GZCS', index: 1, text: '故障次数' },
          { name: 'GZSB', index: 2, text: '故障设备' },
          { name: 'ZL', index: 3, text: '质量' },
          { name: 'GL', index: 4, text: '管理' },
          { name: 'CQFY', index: 5, text: '超期服役' }
        ],
        itemStyle: {
          normal: {
            opacity: 0.8,
            shadowBlur: 15,
            shadowOffsetX: 0,
            shadowOffsetY: 0,
            shadowColor: 'rgba(255, 255, 255, 0.5)'
          }
        },
        echartsData: {
          ssh: {
            baseOption: {
              timeline: {
                axisType: 'category',
                autoPlay: true,
                playInterval: 10000,
                data: [
                  '2002-01-01','2003-01-01','2004-01-01','2005-01-01',
                  '2006-01-01', '2007-01-01','2008-01-01','2009-01-01','2010-01-01',
                  '2011-01-01', '2012-01-01','2013-01-01','2014-01-01','2015-01-01',
                  '2016-01-01','2014-07-01','2018-01-01','2019-01-01',
                ],
                label: {
                  formatter : function(s) {
                    return (new Date(s)).getFullYear();
                  }
                }
              },
              legend: {
                x: 'right',
                data: ['维护支出', '工程支出', '制水支出'],

              },
              calculable : true,
              grid: {
                top: 80,
                bottom: 100,
                tooltip: {
                  trigger: 'axis',
                }
              },
              xAxis: [
                {
                  'type':'category',
                  'axisLabel':{'interval':0},
                  'data':[
                    '瓮安水务有限责任公司','铜仁水务碧江有限责任公司','绥阳水务有限责任公司','三都水务有限责任公司','贵定水务有限责任公司','桐梓水务有限责任公司'
                  ],
                  splitLine: {show: false}
                }
              ],
              yAxis: [
                {
                  type: 'value',
                  name: '（百万元）'
                }
              ],
              series: [

                {name: '维护支出', type: 'bar'},
                {name: '工程支出', type: 'bar'},
                {name: '制水支出', type: 'bar'},
                {
                  name: '支出占比',
                  type: 'pie',
                  center: ['65%', '18%'],
                  radius: '28%',
                  z: 100
                }
              ]
            },
            options: [
              {
                title: {text: '2002贵州水务集团分公司财务支出汇总'},
                series: [

                  {data: dataMap.dataPI['2002']},
                  {data: dataMap.dataSI['2002']},
                  {data: dataMap.dataTI['2002']},
                  {data: [
                      {name: '维护支出', value: dataMap.dataPI['2002sum']},
                      {name: '工程支出', value: dataMap.dataSI['2002sum']},
                      {name: '制水支出',value: dataMap.dataTI['2002sum']}
                    ]}
                ]
              },
              {
                title : {text: '2003贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2003']},
                  {data: dataMap.dataSI['2003']},
                  {data: dataMap.dataTI['2003']},
                  {data: [
                      {name: '维护支出', value: dataMap.dataPI['2003sum']},
                      {name: '工程支出', value: dataMap.dataSI['2003sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2003sum']}
                    ]}
                ]
              },
              {
                title : {text: '2004贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2004']},
                  {data: dataMap.dataSI['2004']},
                  {data: dataMap.dataTI['2004']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2004sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2004sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2004sum']}
                    ]}
                ]
              },
              {
                title : {text: '2005贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2005']},
                  {data: dataMap.dataSI['2005']},
                  {data: dataMap.dataTI['2005']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2005sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2005sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2005sum']}
                    ]}
                ]
              },
              {
                title : {text: '2006贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2006']},
                  {data: dataMap.dataSI['2006']},
                  {data: dataMap.dataTI['2006']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2006sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2006sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2006sum']}
                    ]}
                ]
              },
              {
                title : {text: '2007贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2007']},
                  {data: dataMap.dataSI['2007']},
                  {data: dataMap.dataTI['2007']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2007sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2007sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2007sum']}
                    ]}
                ]
              },
              {
                title : {text: '2008贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2008']},
                  {data: dataMap.dataSI['2008']},
                  {data: dataMap.dataTI['2008']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2008sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2008sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2008sum']}
                    ]}
                ]
              },
              {
                title : {text: '2009贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2009']},
                  {data: dataMap.dataSI['2009']},
                  {data: dataMap.dataTI['2009']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2009sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2009sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2009sum']}
                    ]}
                ]
              },
              {
                title : {text: '2010贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2010']},
                  {data: dataMap.dataSI['2010']},
                  {data: dataMap.dataTI['2010']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2010sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2010sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2010sum']}
                    ]}
                ]
              },
              {
                title : {text: '2011贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2011']},
                  {data: dataMap.dataSI['2011']},
                  {data: dataMap.dataTI['2011']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2011sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2011sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2011sum']}
                    ]}
                ]
              },
              {
                title : {text: '2012贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2012']},
                  {data: dataMap.dataSI['2012']},
                  {data: dataMap.dataTI['2012']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2012sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2012sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2012sum']}
                    ]}
                ]
              },
              {
                title : {text: '2013贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2013']},
                  {data: dataMap.dataSI['2013']},
                  {data: dataMap.dataTI['2013']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2013sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2013sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2013sum']}
                    ]}
                ]
              },
              {
                title : {text: '2014贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2014']},
                  {data: dataMap.dataSI['2014']},
                  {data: dataMap.dataTI['2014']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2014sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2014sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2014sum']}
                    ]}
                ]
              },
              {
                title : {text: '2015贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2015']},
                  {data: dataMap.dataSI['2015']},
                  {data: dataMap.dataTI['2015']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2015sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2015sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2015sum']}
                    ]}
                ]
              },
              {
                title : {text: '2016贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2016']},
                  {data: dataMap.dataSI['2016']},
                  {data: dataMap.dataTI['2016']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2016sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2016sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2016sum']}
                    ]}
                ]
              },
              {
                title : {text: '2017贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2017']},
                  {data: dataMap.dataSI['2017']},
                  {data: dataMap.dataTI['2017']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2017sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2017sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2017sum']}
                    ]}
                ]
              },
              {
                title : {text: '2011贵州水务集团分公司财务支出汇总'},
                series : [

                  {data: dataMap.dataPI['2018']},
                  {data: dataMap.dataSI['2018']},
                  {data: dataMap.dataTI['2018']},
                  {data: [
                      {name: '维护支出',  value: dataMap.dataPI['2018sum']},
                      {name: '工程支出',  value: dataMap.dataSI['2018sum']},
                      {name: '制水支出',    value: dataMap.dataTI['2018sum']}
                    ]}
                ]
              }
            ]
          }
        }
      }
    },
    methods: {}
  }
</script>

<style scoped>

</style>
